/*
 * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.baomidou.mybatisplus.advance.query;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 分页实体
 * @author wanglei
 * @since 2022-03-14
 */
@Data
@Builder
@ApiModel("分页")
@Schema(title = "分页")
@AllArgsConstructor
@NoArgsConstructor
public class DefaultPager<T> implements IPage<T> {

    @ApiModelProperty("数据")
    @Schema(title = "数据")
    private List<T> records;

    @ApiModelProperty("总条数")
    @Schema(title = "总条数")
    private long total;

    @ApiModelProperty("每页多少条")
    @Schema(title = "每页多少条")
    private long size;


    @ApiModelProperty("当前第几页-仅仅后端用")
    @Schema(title = "当前第几页-仅仅后端用")
    private long current;


    @ApiModelProperty("分页扩展字段")
    private Map<String, Object> extMap;


    @Override
    public List<OrderItem> orders() {
        return new ArrayList<>();
    }

    @Override
    public List<T> getRecords() {
        return records;
    }

    @Override
    public IPage<T> setRecords(List<T> records) {
        this.records = records;
        return this;
    }

    @Override
    public IPage<T> setTotal(long total) {
        this.total = total;
        return this;
    }


    @Override
    public IPage<T> setSize(long size) {
        this.size = size;
        return this;
    }

    @Override
    public long getCurrent() {
        return current;
    }

    @Override
    public IPage<T> setCurrent(long current) {
        this.current = current;
        return this;
    }

}
